import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/task/widgets/select_menu.dart';
import 'package:leader_help/page/task/subs/industry/index.dart';
import 'package:leader_help/utils/component/carousel_text.dart';

import 'package:leader_help/utils/component/component.dart';

import 'package:leader_help/utils/util.dart';

import 'controller.dart';
import 'index.dart';

class TaskPage extends StatelessWidget {
  TaskPage({Key? key}) : super(key: key);
  final controller = Get.put(TaskController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: detailAppBar(context,
          leadding: const SizedBox(),
          title: '览全局',
          actions: [
            InkWell(
              onTap: controller.actionGrap,
              child: Row(
                children: [
                  Icon(
                    ProIconUtil.aim,
                    color: Colors.white,
                    size: 18.sp,
                  ),
                  Text(
                    '抓问题',
                    style: pfMediumStyle(color: Colors.white, fontSize: 15.sp),
                  ),
                  SizedBox(
                    width: 10.r,
                  )
                ],
              ),
            )
          ]),
      body: GetBuilder<TaskController>(builder: (logic) {
        return Stack(
          children: [
            GetPlatform.isIOS
                ? SizedBox()
                : Visibility(
                    visible: logic.state.distributeType != 1,
                    child: SizedBox(
                      height: 1.sh,
                      width: 1.sw,
                      child: BMFMapWidget(
                        onBMFMapCreated: logic.onBMFMapCreated,
                        mapOptions: logic.initMapOptions(),
                      ),
                    ),
                  ),
            Visibility(
              visible: logic.state.distributeType == 1,
              child: SizedBox(
                height: 1.sh,
                width: 1.sw,
                child: IndustryPage(),
              ),
            ),
            Positioned(
              top: 0,
              width: Get.width,
              height: 120.r,
              child: const TaskSelectMenuView(),
            ),
            Positioned(
              left: 5.r,
              bottom: 10.h,
              width: 300.w,
              height: 90.r,
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.black45,
                  borderRadius: BorderRadius.circular(5),
                ),
                child: CarouselText(
                  height: 90.r,
                  width: 300.w,
                  list: controller.state.carouselTexts,
                  onTap: controller.actionToPointSmall,
                ),
              ),
            ),
          ],
        );
      }),
      floatingActionButton: FloatingActionButton(
        onPressed: controller.actionToComList,
        backgroundColor: ColorsUtil.red,
        child: Icon(
          ProIconUtil.more,
          color: Colors.white,
          size: 20.r,
        ),
      ),
    );
  }
}
